this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.Ui=this.BX.Landing.Ui||{};this.BX.Landing.Ui.Panel=this.BX.Landing.Ui.Panel||{};this.BX.Landing.Ui.Panel.Formsettingspanel=this.BX.Landing.Ui.Panel.Formsettingspanel||{};(function(t,e,n,i,o,s,a,r,l,c,u,p,g){"use strict";var d;var f=function(t){babelHelpers.inherits(e,t);function e(t){var n;babelHelpers.classCallCheck(this,e);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(e).call(this,t));n.setEventNamespace("BX.Landing.UI.Field.ActionPagesField");n.subscribeFromOptions(c.fetchEventsFromOptions(t));n.setLayoutClass("landing-ui-field-action-pages");p.Dom.append(n.getSuccess(),n.input);p.Dom.append(n.getFailure(),n.input);p.Event.bind(document,"click",n.onDocumentClick.bind(babelHelpers.assertThisInitialized(n)));p.Event.bind(window.top.document,"click",n.onDocumentClick.bind(babelHelpers.assertThisInitialized(n)));return n}babelHelpers.createClass(e,[{key:"onDocumentClick",value:function t(){var e=this.getSuccess().querySelector(".landing-ui-field-action-pages-page-text");var n=this.getFailure().querySelector(".landing-ui-field-action-pages-page-text");p.Dom.attr(e,"contenteditable",null);p.Dom.attr(n,"contenteditable",null)}},{key:"getSuccess",value:function t(){var n=this;return this.cache.remember("success",(function(){return e.createPageBlock({type:"success",title:g.Loc.getMessage("LANDING_FORM_ACTIONS_EDIT_SUCCESS_PAGE_TITLE"),text:n.options.successText,onFocus:function t(){n.emit("onShowSuccess",new p.Event.BaseEvent({data:{show:true}}))},onInput:function t(){n.emit("onChange");n.emit("onShowSuccess",new p.Event.BaseEvent({data:{show:true}}))},onShowClick:function t(){n.emit("onShowSuccess")},onBlur:function t(){n.emit("onBlur")}})}))}},{key:"getFailure",value:function t(){var n=this;return this.cache.remember("failure",(function(){return e.createPageBlock({type:"failure",title:g.Loc.getMessage("LANDING_FORM_ACTIONS_EDIT_FAILURE_PAGE_TITLE"),text:n.options.failureText,onFocus:function t(){n.emit("onShowFailure",new p.Event.BaseEvent({data:{show:true}}))},onInput:function t(){n.emit("onChange");n.emit("onShowFailure",new p.Event.BaseEvent({data:{show:true}}))},onShowClick:function t(){n.emit("onShowFailure")},onBlur:function t(){n.emit("onBlur")}})}))}},{key:"getSuccessText",value:function t(){return this.getSuccess().querySelector(".landing-ui-field-action-pages-page-text").innerText}},{key:"getFailureText",value:function t(){return this.getFailure().querySelector(".landing-ui-field-action-pages-page-text").innerText}},{key:"getValue",value:function t(){return{success:this.getSuccessText(),failure:this.getFailureText()}}}],[{key:"createPageBlock",value:function t(e){var n="landing-ui-field-action-pages-page";var i=function t(i){i.preventDefault();i.stopPropagation();var o=i.currentTarget.closest(".".concat(n,"-inner"));var s=o.querySelector(".".concat(n,"-text"));p.Dom.attr(s,"contenteditable",!s.isContentEditable);if(p.Type.isFunction(e.onEditClick)){e.onEditClick(i)}};var o=function t(e){e.stopPropagation()};var s=function t(n){n.preventDefault();if(p.Type.isFunction(e.onShowClick)){e.onShowClick(n)}};var a=function t(n){n.preventDefault();if(p.Type.isFunction(e.onBlur)){e.onBlur(n)}};var r=function t(n){n.preventDefault();if(p.Type.isFunction(e.onFocus)){e.onFocus(n)}};return p.Tag.render(d||(d=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="'," ","-",'">\n\t\t\t\t<div class="','-title">\n\t\t\t\t\t','\n\t\t\t\t</div>\n\t\t\t\t<div class="','-inner">\n\t\t\t\t\t<div class="','-header">\n\t\t\t\t\t\t<span class="','-header-view" onclick="','">\n\t\t\t\t\t\t\t','\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="','-icon"></div>\n\t\t\t\t\t<div class="','-text" onclick="','" \n\t\t\t\t\t\tonfocus="','" onblur="','" oninput="','">\n\t\t\t\t\t\t','\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="','-footer">\n\t\t\t\t\t\t<span class="','-footer-edit" onclick="','">\n\t\t\t\t\t\t\t',"\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t"])),n,n,e.type,n,e.title,n,n,n,s,g.Loc.getMessage("LANDING_FORM_ACTIONS_EDIT_PAGE_SHOW"),n,n,o,r,a,e.onInput,p.Text.encode(e.text),n,n,i,g.Loc.getMessage("LANDING_FORM_ACTIONS_EDIT_PAGE_EDIT"))}}]);return e}(l.BaseField);var h="/bitrix/js/landing/ui/panel/formsettingspanel/content/actions/dist/images/type1.svg";var v="/bitrix/js/landing/ui/panel/formsettingspanel/content/actions/dist/images/type2.svg";var m="/bitrix/js/landing/ui/panel/formsettingspanel/content/actions/dist/images/type3.svg";var T,I;var b=function(t){babelHelpers.inherits(e,t);function e(t){babelHelpers.classCallCheck(this,e);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(e).call(this,t))}babelHelpers.createClass(e,[{key:"getSuccess",value:function t(){var n=this;return this.cache.remember("success",(function(){return e.createPageBlock({type:"success",title:g.Loc.getMessage("LANDING_FORM_ACTIONS_EDIT_SUCCESS_PAGE_TITLE"),text:n.options.successText,buttonCaption:n.options.buttonCaption,onFocus:function t(){n.emit("onShowSuccess",new p.Event.BaseEvent({data:{show:true}}))},onInput:function t(){n.emit("onChange");n.emit("onShowSuccess",new p.Event.BaseEvent({data:{show:true}}))},onShowClick:function t(){n.emit("onShowSuccess")},onBlur:function t(){n.emit("onBlur")}})}))}},{key:"onDocumentClick",value:function t(){var e=this.getSuccess().querySelector(".landing-ui-field-action-pages-page-text");var n=this.getSuccess().querySelector(".landing-ui-field-action-pages-page-button");var i=this.getFailure().querySelector(".landing-ui-field-action-pages-page-text");p.Dom.attr(e,"contenteditable",null);p.Dom.attr(n,"contenteditable",null);p.Dom.attr(i,"contenteditable",null)}},{key:"getButtonCaptionText",value:function t(){return this.getSuccess().querySelector(".landing-ui-field-action-pages-page-button").innerText}},{key:"getValue",value:function t(){return{success:this.getSuccessText(),buttonCaption:this.getButtonCaptionText(),failure:this.getFailureText()}}}],[{key:"createPageBlock",value:function t(e){var n="landing-ui-field-action-pages-page";var i=function t(i){i.preventDefault();i.stopPropagation();var o=i.currentTarget.closest(".".concat(n,"-inner"));var s=o.querySelector(".".concat(n,"-text"));var a=o.querySelector(".".concat(n,"-button"));p.Dom.attr(s,"contenteditable",!s.isContentEditable);p.Dom.attr(a,"contenteditable",!a.isContentEditable);if(p.Type.isFunction(e.onEditClick)){e.onEditClick(i)}};var o=function t(e){e.stopPropagation()};var s=function t(n){n.preventDefault();if(p.Type.isFunction(e.onShowClick)){e.onShowClick(n)}};var a=function t(n){n.preventDefault();if(p.Type.isFunction(e.onBlur)){e.onBlur(n)}};var r=function t(n){n.preventDefault();if(p.Type.isFunction(e.onFocus)){e.onFocus(n)}};var l="";if(e.type==="success"){var c=p.Text.encode(e.buttonCaption)||g.Loc.getMessage("LANDING_FORM_ACTIONS_REFILL_CAPTION");l=p.Tag.render(T||(T=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="','-button" onclick="','" \n\t\t\t\t\tonfocus="','" onblur="','" oninput="','">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t"])),n,o,r,a,e.onInput,c)}return p.Tag.render(I||(I=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="'," ","-",'">\n\t\t\t\t<div class="','-title">\n\t\t\t\t\t','\n\t\t\t\t</div>\n\t\t\t\t<div class="','-inner">\n\t\t\t\t\t<div class="','-header">\n\t\t\t\t\t\t<span class="','-header-view" onclick="','">\n\t\t\t\t\t\t\t','\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="','-icon"></div>\n\t\t\t\t\t<div class="','-text" onclick="','" onfocus="','" onblur="','"  \n\t\t\t\t\t\toninput="','">\n\t\t\t\t\t\t',"\n\t\t\t\t\t</div>\n\t\t\t\t\t",'\n\t\t\t\t\t<div class="','-footer">\n\t\t\t\t\t\t<span class="','-footer-edit" onclick="','">\n\t\t\t\t\t\t\t',"\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t"])),n,n,e.type,n,e.title,n,n,n,s,g.Loc.getMessage("LANDING_FORM_ACTIONS_EDIT_PAGE_SHOW"),n,n,o,r,a,e.onInput,p.Text.encode(e.text),l,n,n,i,g.Loc.getMessage("LANDING_FORM_ACTIONS_EDIT_PAGE_EDIT"))}}]);return e}(f);var L=function(t){babelHelpers.inherits(n,t);function n(t){var e;babelHelpers.classCallCheck(this,n);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(n).call(this,t));e.setEventNamespace("BX.Landing.UI.Panel.FormSettingsPanel.ActionsContent");p.Dom.addClass(e.getLayout(),"landing-ui-actions-content-wrapper");e.addItem(e.getHeader());e.addItem(e.getTypeButtons());if(e.options.form){e.options.form.sent=false;e.options.form.error=false}var i=function t(){e.options.form.sent=false;e.options.form.error=false};var o=function t(n){var i=n.data.show||null;e.options.formOptions.result=e.getValue().result;e.options.form.stateText=e.options.formOptions.result.failure.text;e.options.form.sent=i===null?!e.options.form.sent:i;e.options.form.error=e.options.form.sent};e.getActionPages().subscribe("onShowSuccess",(function(t){var n=t.data.show||null;e.options.formOptions.result=e.getValue().result;e.options.form.stateText=e.options.formOptions.result.success.text;e.options.form.sent=n===null?!e.options.form.sent:n;e.options.form.error=false})).subscribe("onShowFailure",o).subscribe("onBlur",i);e.getRefillActionPages().subscribe("onShowSuccess",(function(t){var n=t.data.show||null;e.options.formOptions.result=e.getValue().result;e.options.form.stateText=e.options.formOptions.result.success.text;e.options.form.stateButton.text=e.options.formOptions.result.refill&&e.options.formOptions.result.refill.active?e.options.formOptions.result.refill.caption:"";e.options.form.sent=n===null?!e.options.form.sent:n;e.options.form.error=false;if(!p.Type.isFunction(e.options.form.stateButton.handler)){e.options.form.stateButton.handler=function(){}}})).subscribe("onShowFailure",o).subscribe("onBlur",i);return e}babelHelpers.createClass(n,[{key:"getHeader",value:function t(){return this.cache.remember("header",(function(){return new e.HeaderCard({title:g.Loc.getMessage("LANDING_FORM_ACTIONS_TITLE")})}))}},{key:"getMessage",value:function t(e){return new u.MessageCard({id:"actionsMessage"+e,header:g.Loc.getMessage("LANDING_ACTIONS_MESSAGE_HEADER_"+e),description:g.Loc.getMessage("LANDING_ACTIONS_MESSAGE_DESCRIPTION_"+e),restoreState:true})}},{key:"getTypeButtons",value:function t(){var e=this;return this.cache.remember("typeButtons",(function(){return new i.RadioButtonField({selectable:true,value:function(){if(e.options.formOptions.result.refill.active){return"type3"}if(p.Type.isStringFilled(e.options.formOptions.result.success.url)||p.Type.isStringFilled(e.options.formOptions.result.failure.url)){return"type2"}return"type1"}(),items:[{id:"type1",title:g.Loc.getMessage("LANDING_FORM_ACTIONS_TYPE_1"),icon:"landing-ui-form-actions-type1"},{id:"type2",title:g.Loc.getMessage("LANDING_FORM_ACTIONS_TYPE_2"),icon:"landing-ui-form-actions-type2"},{id:"type3",title:g.Loc.getMessage("LANDING_FORM_ACTIONS_TYPE_3"),icon:"landing-ui-form-actions-type3"}],onChange:e.onTypeChange.bind(e)})}))}},{key:"getCheckbox",value:function t(){return this.cache.remember("checkbox",(function(){return new BX.Landing.UI.Field.Checkbox({items:[{name:g.Loc.getMessage("LANDING_FORM_ACTIONS_CHECKBOX_TITLE"),value:true}]})}))}},{key:"getTypeDropdown",value:function t(){var e=this;return this.cache.remember("typeDropdown",(function(){var t=new s.PresetField({events:{onClick:function t(){e.clear();e.addItem(e.getHeader());e.addItem(e.getTypeButtons())}}});t.setTitle(g.Loc.getMessage("LANDING_FORM_ACTIONS_TYPE_DROPDOWN_TITLE"));t.setIcon(h);return t}))}},{key:"getSuccessLinkField",value:function t(){var e=this;return this.cache.remember("successLinkField",(function(){return new a.TextField({title:g.Loc.getMessage("LANDING_FORM_ACTIONS_SUCCESS_FIELD_TITLE"),placeholder:"http://",textOnly:true,content:e.options.formOptions.result.success.url,onInput:e.onChange.bind(e)})}))}},{key:"getFailureLinkField",value:function t(){var e=this;return this.cache.remember("failureLinkField",(function(){return new a.TextField({title:g.Loc.getMessage("LANDING_FORM_ACTIONS_FAILURE_FIELD_TITLE"),placeholder:"http://",textOnly:true,content:e.options.formOptions.result.failure.url,onInput:e.onChange.bind(e)})}))}},{key:"getRefillCaptionField",value:function t(){var e=this;return this.cache.remember("refillCaptionFill",(function(){return new a.TextField({title:g.Loc.getMessage("LANDING_FORM_ACTIONS_REFILL_CAPTION_FIELD_TITLE"),textOnly:true,content:e.options.formOptions.result.refill.caption||g.Loc.getMessage("LANDING_FORM_ACTIONS_REFILL_CAPTION"),onInput:e.onChange.bind(e)})}))}},{key:"getDelayField",value:function t(){var e=this;return this.cache.remember("delayField",(function(){return new BX.Landing.UI.Field.Dropdown({selector:"redirectDelay",title:g.Loc.getMessage("LANDING_FORM_ACTIONS_DELAY_TITLE"),content:e.options.formOptions.result.redirectDelay,items:Array.from({length:11},(function(t,e){return{name:"".concat(e," ").concat(g.Loc.getMessage("LANDING_FORM_ACTIONS_DELAY_ITEM")),value:e}}))})}))}},{key:"onChange",value:function t(){this.emit("onChange",{skipPrepare:true})}},{key:"getActionPages",value:function t(){var e=this;return this.cache.remember("actionPages",(function(){return new f({successText:e.options.formOptions.result.success.text,failureText:e.options.formOptions.result.failure.text,onChange:e.onChange.bind(e)})}))}},{key:"getRefillActionPages",value:function t(){var e=this;return this.cache.remember("refillActionPages",(function(){return new b({successText:e.options.formOptions.result.success.text,buttonCaption:e.options.formOptions.result.refill.caption,failureText:e.options.formOptions.result.failure.text,onChange:e.onChange.bind(e)})}))}},{key:"onTypeChange",value:function t(e){var n=e.getData();var i=this.getTypeDropdown();this.clear();this.addItem(this.getHeader());this.addItem(this.getMessage(n.item.id));this.addItem(i);i.setLinkText(n.item.title.replace(/&nbsp;/," "));if(n.item.id==="type1"){i.setIcon(h);this.addItem(this.getActionPages())}if(n.item.id==="type2"){i.setIcon(v);this.addItem(this.getSuccessLinkField());this.addItem(this.getFailureLinkField());this.addItem(this.getDelayField())}if(n.item.id==="type3"){i.setIcon(m);this.addItem(this.getRefillActionPages())}}},{key:"getValue",value:function t(){var e=this.getTypeButtons().getValue()==="type3";var n=!e?this.getActionPages().getValue():this.getRefillActionPages().getValue();var i=this.getTypeButtons().getValue()==="type2";return{result:{success:{text:n.success,url:i?p.Text.decode(this.getSuccessLinkField().getValue()):""},failure:{text:n.failure,url:i?p.Text.decode(this.getFailureLinkField().getValue()):""},redirectDelay:this.getDelayField().getValue(),refill:{active:e,caption:e?n.buttonCaption:""}}}}}]);return n}(n.ContentWrapper);t.default=L})(this.BX.Landing.Ui.Panel.Formsettingspanel.Content=this.BX.Landing.Ui.Panel.Formsettingspanel.Content||{},BX.Landing.UI.Card,BX.Landing.UI.Panel,BX.Landing.UI.Field,BX.Event,BX.Landing.UI.Field,BX.Landing.UI.Field,BX,BX.Landing.UI.Field,BX.Landing.UI.Component,BX.Landing.UI.Card,BX,BX.Landing);
//# sourceMappingURL=actions.bundle.map.js